function toUnderline(str) {
    return str.replace(/([A-Z])/g, '_$1').toLowerCase();
}


const sqlCondition = (data) => {
    if (JSON.stringify(data) === '{}') {
        return null
    }
    const sqlObj = {}
    for (const dataKey in data) {
        let sqlObjKey = toUnderline(dataKey)
        sqlObj[sqlObjKey] = data[dataKey]
    }
    return sqlObj
}

// console.log(sqlCondition({userNumber: 123}))

module.exports = sqlCondition
